/*
 * Group:PrePool K9-357 
 * 8/2010
 */
package control;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;

import form.ManageHome;
import form.S09Form;
import form.S14Form;

import blo.ApproveBLO;
import blo.ManagerindictBLO;

/**
 *
 */
public class ApproverCheckSuggestion extends BaseControl {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public S09Form procApprove(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {
		S09Form result = new S09Form();
		int dictID = Integer.valueOf(request.getParameter("dictID"));
		result.setDicID(dictID);
		result.setDestination("/WEB-INF/jsp/S14_Approver_CheckSuggestion.jsp");
		String[] wIDs = request.getParameterValues("wordID");
		String username = request.getParameter("username");
		ApproveBLO aBLO = new ApproveBLO();
		for(int i=0; i<wIDs.length;i++){
			aBLO.approve(Integer.valueOf(wIDs[i]), username);
		}

		return result;
	}

	public void procDiscard(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {

	}

	public ManageHome procBack(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {
	String username = (String) request.getPortletSession().getAttribute("username", PortletSession.APPLICATION_SCOPE);
	//LOG.info(username);
	int userrole = (Integer) request.getPortletSession().getAttribute("userrole", PortletSession.APPLICATION_SCOPE);
	blo.UsersBLO loginUser = new blo.UsersBLO();
	blo.ManagerindictBLO manageBLO = new ManagerindictBLO();
	ManageHome result = new ManageHome();
	
	result.setApproverManager(manageBLO.getApproverManagement(username));
	result.setReviewerManager(manageBLO.getReviewerManagement(username));
	result.setLoginUsername(username);
	result.setRole(userrole);
	return result;

}
}
